
import Head from 'next/head'

<Head>
  <script>
    {
      `(function() {
         var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
       })();`
    }
  </script>
</Head>

![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif)





# 使用Jira工具[#](#jira-tool "Permalink to this headline")

本教程将介绍如何使用Jira工具。

Jira工具允许代理与给定的Jira实例交互，执行诸如搜索问题和创建问题等操作，该工具包装了atlassian-python-api库，了解更多请参见：https://atlassian-python-api.readthedocs.io/jira

要使用此工具，必须首先设置以下环境变量：

`JIRA_API_TOKEN`

`JIRA_USERNAME`

`JIRA_INSTANCE_URL`
 







```python
%pip install atlassian-python-api

 ``` 

```python
import os
from langchain.agents import AgentType
from langchain.agents import initialize_agent
from langchain.agents.agent_toolkits.jira.toolkit import JiraToolkit
from langchain.llms import OpenAI
from langchain.utilities.jira import JiraAPIWrapper
 ``` 








```python
os.environ["JIRA_API_TOKEN"] = "abc"
os.environ["JIRA_USERNAME"] = "123"
os.environ["JIRA_INSTANCE_URL"] = "https://jira.atlassian.com"
os.environ["OPENAI_API_KEY"] = "xyz"
 ``` 








```python
llm = OpenAI(temperature=0)
jira = JiraAPIWrapper()
toolkit = JiraToolkit.from_jira_api_wrapper(jira)
agent = initialize_agent(
    toolkit.get_tools(),
    llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True
)
 ``` 








```python
agent.run("make a new issue in project PW to remind me to make more fried rice")
 ``` 






```python
> Entering new AgentExecutor chain...
 I need to create an issue in project PW
Action: Create Issue
Action Input: {"summary": "Make more fried rice", "description": "Reminder to make more fried rice", "issuetype": {"name": "Task"}, "priority": {"name": "Low"}, "project": {"key": "PW"}}
Observation: None
Thought: I now know the final answer
Final Answer: A new issue has been created in project PW with the summary "Make more fried rice" and description "Reminder to make more fried rice".

> Finished chain.
 ``` 




```python
'A new issue has been created in project PW with the summary "Make more fried rice" and description "Reminder to make more fried rice".'
 ``` 





